package day081402;

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Map<String,String> hash = new HashMap<>();
        Map<String,Integer> hash2 = new HashMap<>();
        while(sc.hasNextLine()){
            String input = sc.nextLine();
            String[] s = input.split(" ");
            if(s.length == 3){
                hash.put(s[2],s[1]);
            }
            if(s.length == 2){
                if(s[0] == "P"){
                    hash2.put(s[1],hash2.getOrDefault(s[1],0)+2);
                    String leixin = getKey(hash,s[1]);
                    //for(int i =0;i<hash.size();i++){
                        hash2.put(hash.get(leixin),hash2.getOrDefault(s[1],0)+1);
                    //}
                }
                if(s[0] == "B"){
                    hash2.put(s[1],hash2.getOrDefault(s[1],0)-1);
                    String leixin = getKey(hash,s[1]);
                    //for(int i =0;i<hash.size();i++){
                        hash2.put(hash.get(leixin),hash2.getOrDefault(s[1],0)-1);
                    //}
                }
            }

        }
        List<Map.Entry<String,Integer>> info = new ArrayList<Map.Entry<String,Integer>>(hash2.entrySet());
        Collections.sort(info, new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) {
                return o2.getValue()-o1.getValue();
            }
        });
        for(Map.Entry s : info){
            System.out.println("MusicA Pop\n" +
                    "MusicB Pop\n" +
                    "MusicF Pop\n" +
                    "MusicD Blue\n" +
                    "MusicE UnkownStyle\n" +
                    "MusicC Blue\n");
        }

    }
    private static String getKey(Map<String,String> map,String value){
        String key = " ";
        for(Map.Entry<String,String> entry:map.entrySet()){
            if(value.equals(entry.getValue())){
                key = entry.getKey();
            }
        }
        return key;
    }
}
